#include <types.h>
#include <sys_config.h>
#include <retcode.h>
#include <api/libc/string.h>
#include <api/libc/printf.h>

#include <api/libmp/pe.h>
#include "video_engine.h"
#include "plugin.h"
#include "mpgfiledecoder.h"

static BOOL MPG_IllegalOperation(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	 return FALSE;
}


static BOOL MPG_LegalOperation(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	 return TRUE;
}


static BOOL MPG_Stop_to_Play(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_ON;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Play_to_Stop(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_STOP;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_OFF;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Play_to_Play(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	 if(SearchTime != INVALID_TIME)
	 {
			pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
			pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_ON;
			pDecoderCtrl->ScrRatio = PlaySpeed;
			pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
			pDecoderCtrl->PlayDir = FORWARD_PLAY;
			pDecoderCtrl->SearchTime = SearchTime;
			pDecoderCtrl->renew = TRUE;
			return TRUE;
	 }
	 return TRUE;
}


static BOOL MPG_Play_to_Pause_Step(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_STEP;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_OFF;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Play_to_FFx2(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
    if(PlaySpeed == 1) 
		PlaySpeed++;
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_OFF;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}

static BOOL MPG_Play_to_FFx4(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
    pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_SKIP_B_P;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_OFF;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Play_to_FFx8x16x32(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	return MPG_Play_to_FFx4(pDecoderCtrl,  PlaySpeed, SearchTime);
}


static BOOL MPG_Play_to_Slow(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_OFF;
	pDecoderCtrl->ScrRatio = PlaySpeed; 
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Play_to_Rev(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_SKIP_B_P;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_OFF;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = BACKWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Pause_Step_to_Stop(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_STOP;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_OFF;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Pause_Step_to_Play(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_ON;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Pause_Step_to_Pause_Step(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_STEP;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Pause_Step_to_FFx2(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Pause_Step_to_FFx4(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_SKIP_B_P;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Pause_Step_to_FFx8x16x32(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_SKIP_B_P;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Pause_Step_to_Slow(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed; //1/2
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}

static BOOL MPG_Pause_Step_to_Rev(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_SKIP_B_P;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = BACKWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx2_to_Stop(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_STOP;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_OFF;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx2_to_Play(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_ON;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx2_to_Pause_Step(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_STEP;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx2_to_FFx4(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_SKIP_B_P;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx2_to_FFx8x16x32(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_SKIP_B_P;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx2_to_Slow(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed; //1/2
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx2_to_Rev(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_SKIP_B_P;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = BACKWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx4_to_Stop(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	return MPG_FFx2_to_Stop(pDecoderCtrl,  PlaySpeed, SearchTime);
}


static BOOL MPG_FFx4_to_Play(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_ON;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx4_to_Pause_Step(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_STEP;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx4_to_FFx2(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx4_to_FFx8x16x32(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	 pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_SKIP_B_P;
	 pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	 pDecoderCtrl->ScrRatio = PlaySpeed;
	 pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	 pDecoderCtrl->PlayDir = FORWARD_PLAY;
	 pDecoderCtrl->SearchTime = INVALID_TIME;
	 pDecoderCtrl->renew = TRUE;
	 return TRUE;
}


static BOOL MPG_FFx4_to_Slow(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed; //1/2
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx4_to_Rev(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_SKIP_B_P;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = BACKWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx8x16x32_to_Stop(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	return MPG_FFx2_to_Stop(pDecoderCtrl,  PlaySpeed, SearchTime);
}


static BOOL MPG_FFx8x16x32_to_Play(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_ON;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx8x16x32_to_Pause_Step(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_STEP;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx8x16x32_to_FFx2(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx8x16x32_to_FFx4(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_SKIP_B_P;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx8x16x32_to_FFx8x16x32(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_SKIP_B_P;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx8x16x32_to_Slow(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_FFx8x16x32_to_Rev(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_SKIP_B_P;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = BACKWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Slow_to_Stop(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_STOP;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_OFF;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Slow_to_Play(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_ON;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Slow_to_Pause_Step(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_STEP;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Slow_to_FFx2(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Slow_to_FFx4(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_SKIP_B_P;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Slow_to_FFx8x16x32(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_SKIP_B_P;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Slow_to_Slow(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_NORMAL;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed; //1/2
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = FORWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}

static BOOL MPG_Slow_to_Rev(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_SKIP_B_P;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = BACKWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


static BOOL MPG_Rev_to_Stop(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	 return MPG_FFx8x16x32_to_Stop(pDecoderCtrl,  PlaySpeed, SearchTime);
}


static BOOL MPG_Rev_to_Play(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	 return MPG_FFx8x16x32_to_Play(pDecoderCtrl,  PlaySpeed, SearchTime);
}


static BOOL MPG_Rev_to_Pause_Step(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	 return MPG_FFx8x16x32_to_Pause_Step(pDecoderCtrl,  PlaySpeed, SearchTime);
}


static BOOL MPG_Rev_to_FFx2(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	 return MPG_FFx8x16x32_to_FFx2(pDecoderCtrl,  PlaySpeed, SearchTime);
}


static BOOL MPG_Rev_to_FFx4(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	 return MPG_FFx8x16x32_to_FFx4(pDecoderCtrl,  PlaySpeed, SearchTime);
}


static BOOL MPG_Rev_to_FFx8x16x32(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	 return MPG_FFx8x16x32_to_FFx8x16x32(pDecoderCtrl,  PlaySpeed, SearchTime);
}


static BOOL MPG_Rev_to_Slow(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	 return MPG_FFx8x16x32_to_Slow(pDecoderCtrl,  PlaySpeed, SearchTime);
}


static BOOL MPG_Rev_to_Rev(t2DecoderControl *pDecoderCtrl, int PlaySpeed, DWORD SearchTime)
{
	pDecoderCtrl->VideoPlaymode = VIDEO_PLAY_MODE_SKIP_B_P;
	pDecoderCtrl->AudioPlaymode = AUDIO_PLAY_MODE_NONE;
	pDecoderCtrl->ScrRatio = PlaySpeed;
	pDecoderCtrl->StreamType = MPEG_12_FILE_STREAM;
	pDecoderCtrl->PlayDir = BACKWARD_PLAY;
	pDecoderCtrl->SearchTime = INVALID_TIME;
	pDecoderCtrl->renew = TRUE;
	return TRUE;
}


AF_PE_FunctionTable dct_MPG =
{
	{
		MPG_LegalOperation,						// Stop to Stop,
		MPG_Stop_to_Play,						// Stop to Play
		MPG_IllegalOperation,					// Stop to Pause/Step,
		MPG_IllegalOperation,					// Stop to FFx2,
		MPG_IllegalOperation,					// Stop to FFx4,
		MPG_IllegalOperation,					// Stop to FFx8x16x32 and reverse,
		MPG_IllegalOperation,					// Stop to Slow
		MPG_IllegalOperation,					// Stop to reverse
		MPG_IllegalOperation                    // Stop to Resume Stop
	},
	{
		MPG_Play_to_Stop,						// Play to Stop
		MPG_Play_to_Play,						// Play to Play,
		MPG_Play_to_Pause_Step,					// Play to Pause/Step,
		MPG_Play_to_FFx2,						// Play to FFx2,
		MPG_Play_to_FFx4,						// Play to FFx4,
		MPG_Play_to_FFx8x16x32,				 	// Play to FFx8x16x32 and reverse,
		MPG_Play_to_Slow,						// Play to Slow
		MPG_Play_to_Rev,					    // Play to reverse
		MPG_IllegalOperation                 // Play to Resume Stop
	},
	{
		MPG_Pause_Step_to_Stop,					// Pause/Step to Stop,
		MPG_Pause_Step_to_Play,					// Pause/Step to Play,
		MPG_Pause_Step_to_Pause_Step,			// Pause/Step to Pause/Step,
		MPG_Pause_Step_to_FFx2,					// Pause/Step to FFx2,
		MPG_Pause_Step_to_FFx4,					// Pause/Step to FFx4,
		MPG_Pause_Step_to_FFx8x16x32,		 	// Pause/Step to FFx8x16x32 and reverse,
		MPG_Pause_Step_to_Slow,					// Pause/Step to Slow
		MPG_Pause_Step_to_Rev,					// Pause/Step to reverse
		MPG_IllegalOperation           // Pause/Step to Resume Stop
	},
	{
		MPG_FFx2_to_Stop,						// FFx2 to Stop,
		MPG_FFx2_to_Play,						// FFx2 to Play,
		MPG_FFx2_to_Pause_Step,					// FFx2 to Pause/Step,
		MPG_LegalOperation,						// FFx2 to FFx2,
		MPG_FFx2_to_FFx4,						// FFx2 to FFx4,
		MPG_FFx2_to_FFx8x16x32,				 	// FFx2 to FFx8x16x32 and reverse,
		MPG_FFx2_to_Slow,						// FFx2 to Slow
	    MPG_FFx2_to_Rev,						// FFx2 to reverse
		MPG_IllegalOperation                 // FFx2 to Resume Stop
	},
	{
		MPG_FFx4_to_Stop,						// FFx4 to Stop,
		MPG_FFx4_to_Play,						// FFx4 to Play,
		MPG_FFx4_to_Pause_Step,					// FFx4 to Pause/Step,
		MPG_FFx4_to_FFx2,						// FFx4 to FFx2,
		MPG_LegalOperation,						// FFx4 to FFx4,
		MPG_FFx4_to_FFx8x16x32,				 	// FFx4 to FFx8x16x32 and reverse,
		MPG_FFx4_to_Slow,						// FFx4 to Slow
	    MPG_FFx4_to_Rev,						// FFx4 to reverse
		MPG_IllegalOperation                 // FFx4 to Resume Stop
	},
	{
		MPG_FFx8x16x32_to_Stop,				 	// FFx8x16x32 to Stop,
		MPG_FFx8x16x32_to_Play,				 	// FFx8x16x32 to Play,
		MPG_FFx8x16x32_to_Pause_Step,		 	// FFx8x16x32 to Pause/Step,
		MPG_FFx8x16x32_to_FFx2,				 	// FFx8x16x32 to FFx2,
		MPG_FFx8x16x32_to_FFx4,				 	// FFx8x16x32 to FFx4,
		MPG_FFx8x16x32_to_FFx8x16x32,			// FFx8x16x32 to FFx8x16x32 and reverse,
		MPG_FFx8x16x32_to_Slow,				 	// FFx8x16x32 to Slow
		MPG_FFx8x16x32_to_Rev,				 	// FFx8x16x32 to reverse
		MPG_IllegalOperation           // FFx8x16x32 to Resume Stop
	},
	{
		MPG_Slow_to_Stop,						// Slow to Stop,
		MPG_Slow_to_Play,						// Slow to Play,
		MPG_Slow_to_Pause_Step,					// Slow to Pause/Step,
		MPG_Slow_to_FFx2,						// Slow to FFx2,
		MPG_Slow_to_FFx4,						// Slow to FFx4,
		MPG_Slow_to_FFx8x16x32,				 	// Slow to FFx8x16x32,
		MPG_Slow_to_Slow,						// Slow to Slow
	    MPG_Slow_to_Rev,					    // Slow to reverse
		MPG_IllegalOperation                  // Rev to Resume Stop
	},
	{
		MPG_Rev_to_Stop,				 		// Rev to Stop,
		MPG_Rev_to_Play,				 		// Rev to Play,
		MPG_Rev_to_Pause_Step,		 			// Rev to Pause/Step,
		MPG_Rev_to_FFx2,				 		// Rev to FFx2,
		MPG_Rev_to_FFx4,				 		// Rev to FFx4,
		MPG_Rev_to_FFx8x16x32,				 	// Rev to Rev and reverse,
		MPG_Rev_to_Slow,				 		// Rev to Slow
		MPG_Rev_to_Rev,				 			// Rev to reverse
		MPG_IllegalOperation
	},
	{
        MPG_IllegalOperation,                // Resume Stop to Stop
        MPG_IllegalOperation,                // Resume Stop to Play
        MPG_IllegalOperation,                   // Resume Stop to Pause/Step
        MPG_IllegalOperation,                   // Resume Stop to FFx2
        MPG_IllegalOperation,                   // Resume Stop to FFx4
        MPG_IllegalOperation,                   // Resume Stop to FFx8x16x32
        MPG_IllegalOperation,                   // Resume Stop to Slow
        MPG_IllegalOperation,                   // Resume Stop to Reserse
        MPG_IllegalOperation                    // Resume Stop to Resume Stop
	},
};


PAF_PE_FunctionTable DC_GetMPGTable(void)
{
	return &dct_MPG;
}

